function (state)
    if ((UnitExists("target") == false) or (UnitCanAttack("player","target") == false) or UnitIsDead("target") or (GetShapeshiftForm() ~= 3)) then
        state[""] = {changed = false, show = false, icon = nil}
        return false
    end
    if not aura_env.lastRefresh or aura_env.lastRefresh < GetTime() - 0.1 then
        aura_env.lastRefresh = GetTime()
    else
        return true
    end

    local SpellLists = {
        "超级加速器",--1
        "狂暴",--2
        "精灵之火（野性）",--3
        "割裂",--4
        "野蛮咆哮",--5
        "裂伤（豹）",--6
        "猛虎之怒",--7
        "斜掠",--8
        "横扫（豹）",--9
        "凶猛撕咬",--10
        "撕碎",--11
        "攻击"--12
    }
    local NextSpellName = aura_env.LastSpellName
    local Energy = UnitPower("player", 3)
    local CP = GetComboPoints("player", "target")
    local inMeleeRange = (IsSpellInRange("裂伤（豹）", "target") == 1)
    local inCombat = UnitAffectingCombat("player")
    local inBossFight =( IsEncounterInProgress() or UnitLevel("target") == -1)
    local GCD = aura_env.getSpellCD(61304)
    local FFCD = aura_env.getSpellCD(16857)
    local FuryCD = aura_env.getSpellCD(50213)
    local GloveCD = aura_env.getItemCD(10)
    local BerserkCD = aura_env.getSpellCD(50334)
    -- 清晰预兆（Omen of Clarity）的剩余时间
    local OOCDuration = aura_env.getBuff("player", 16870, "HELPFUL|PLAYER")
    -- 野蛮咆哮的剩余时间
    local RoarDuration = aura_env.getBuff("player", 52610, "HELPFUL|PLAYER")
    -- 猛虎之怒的剩余时间
    local FuryDuration = aura_env.getBuff("player", 50213, "HELPFUL|PLAYER")
    -- 狂暴的剩余时间
    local BerserkDuration = aura_env.getBuff("player", 50334, "HELPFUL|PLAYER")
    -- 斜掠（Rake）的剩余时间
    local RakeDuration = aura_env.getDebuff("target", 48574, "HARMFUL|PLAYER")
    -- 割裂（Rip）的剩余时间
    local RipDuration = aura_env.getDebuff("target", 49800, "HARMFUL|PLAYER")
    -- 目标是否有裂伤（Mangle）减益的剩余时间
    local hasMangle = ((aura_env.getDebuff("target", 48566, "HARMFUL") > aura_env.castWindow) or (aura_env.getDebuff("target", 48564, "HARMFUL") > aura_env.castWindow) or (aura_env.getDebuff("target", 46857, "HARMFUL") > aura_env.castWindow) or (aura_env.getDebuff("target", 46855, "HARMFUL") > aura_env.castWindow))

    for i = 1, 1 do
        if((inCombat == false) and (OOCDuration == 0)) then
            NextSpellName = "精灵之火（野性）"
            break
        elseif aura_env.HekiliMode then
            NextSpellName = select(1, GetSpellInfo(aura_env.HekiliSpellID))
            if (aura_env.findSpellIndex(SpellLists, NextSpellName) == 0) then
                NextSpellName = "攻击"
            end
            if ((NextSpellName == "割裂") and (RipDuration > 0)) then
                NextSpellName = "攻击"
            elseif ((NextSpellName == "斜掠") and (RakeDuration > 0))then
                NextSpellName = "攻击"
            end
            --print("HekiliSpellName: ", NextSpellName, aura_env.HekiliSpellID)
            break
        else
            if (aura_env.config.autoAccelerators and inCombat and inMeleeRange and (GloveCD < GCD) and (RoarDuration >= 1)) then
                NextSpellName = "超级加速器"
                break
            end

            if (inCombat and (GCD <= 1))then
                if (aura_env.config.autoBerserk and inBossFight and (BerserkCD < aura_env.castWindow) and (FuryDuration > 1) and (RoarDuration > 8)) then
                    NextSpellName = "狂暴"
                    break
                end

                if ((FFCD <= 1) and (OOCDuration == 0)) then
                    if(((BerserkDuration == 0) and (Energy <= 85) and ((CP >= 5) and (RipDuration > 1)) or (CP < 5)) or
                            ((BerserkDuration >= aura_env.castWindow) and (Energy <= 15) and ((CP >= 5) and (RipDuration > 2)) or (CP < 5))) then
                        NextSpellName = "精灵之火（野性）"
                        break
                    end
                end

                if (inMeleeRange and (aura_env.intoSmartAOE == false) and hasMangle and (RipDuration == 0) and (CP >= 5) and (RoarDuration >= 0.5)) then
                    NextSpellName = "割裂"
                    break
                end
                if (((RoarDuration < 0.5) and (CP >= 1)) or
                        ((RipDuration > 0) and (RoarDuration > 0) and (OOCDuration ==0) and (RipDuration <= (5*CP-16)) and (RoarDuration <= RipDuration +4))) then
                    NextSpellName = "野蛮咆哮"
                    break
                end

                if(inMeleeRange and (aura_env.intoSmartAOE == false) and (hasMangle == false)) then
                    NextSpellName = "裂伤（豹）"
                    break
                end

                if(aura_env.config.autoFury and inMeleeRange and (FuryCD < aura_env.castWindow) and (Energy < 35) and (BerserkDuration == 0)) then
                    NextSpellName = "猛虎之怒"
                    break
                end

                if(inMeleeRange and (RakeDuration == 0) and
                        (
                                ((CP ==0) and (RoarDuration == 0)) or
                                        (
                                                ((aura_env.intoSmartAOE == false) and hasMangle and (RoarDuration > aura_env.castWindow) and
                                                        (
                                                                ((RipDuration > 0) and (CP >=5) and (OOCDuration == 0) and (BerserkDuration == 0)) or
                                                                        ((CP < 5) and (OOCDuration == 0) and (BerserkDuration == 0)) or
                                                                        ((OOCDuration > 0) and (RipDuration == 0) and (CP < 5)) or
                                                                        ((RipDuration == 0) and (BerserkDuration > 0))
                                                        )
                                                )
                                        )
                        )
                ) then
                    NextSpellName = "斜掠"
                    break
                end

                if(inMeleeRange and aura_env.intoSmartAOE and ((RoarDuration > aura_env.castWindow) or (OOCDuration > 0))) then
                    NextSpellName = "横扫（豹）"
                    break
                end

                if(aura_env.config.autoBite and (aura_env.intoSmartAOE == false) and inMeleeRange and hasMangle and (CP >= 5) and
                        (
                                ((RoarDuration >= 3) and (RipDuration > 8)) or
                                        ((FuryCD <= 4) and
                                                (
                                                        ((RoarDuration < 3) and (RipDuration > 8)) or
                                                                ((RoarDuration >11) and (RipDuration < 4)) or
                                                                ((RoarDuration >= 7) and (RoarDuration <= 11) and (RoarDuration > (RipDuration+3)))
                                                )
                                        )
                        ) and
                        (
                                ((BerserkDuration == 0) and (OOCDuration == 0) and (Energy < 55)) or
                                        ((BerserkDuration == 0) and (OOCDuration > 0) and (Energy < 20)) or
                                        ((BerserkDuration > 0) and (OOCDuration == 0) and (Energy < 27)) or
                                        ((BerserkDuration > 0) and (OOCDuration > 0) and (Energy < 10))
                        )
                ) then
                    NextSpellName = "凶猛撕咬"
                    break
                end

                if((aura_env.intoSmartAOE == false) and inMeleeRange) then
                    if((RipDuration > aura_env.castWindow) and (RoarDuration == 0) and (CP ==0)) then
                        NextSpellName = "撕碎"
                        break
                    elseif(hasMangle and (RoarDuration > aura_env.castWindow) and ((RipDuration > aura_env.castWindow) or (RakeDuration > aura_env.castWindow)) and
                            (
                                    ((BerserkDuration > 0) and ((CP < 5) or ((CP >= 5) and (Energy > 27)))) or
                                            ((BerserkDuration == 0) and
                                                    (
                                                            ((CP >= 5) and (RipDuration >= 1) and ((Energy >= 85) or (OOCDuration > 0))) or
                                                                    ((CP < 5) and ((Energy >= 62) or (RipDuration == 0) or (OOCDuration > 0))) or
                                                                    ((Energy >= 62) and((FuryCD < 2) or (FFCD < 2))) or
                                                                    ((RipDuration >= 1) and ((GetCritChance() > 74) or (GetArmorPenetration() > 92)))
                                                    )
                                            )
                            )
                    ) then
                        NextSpellName = "撕碎"
                        break
                    end
                end
            end
            NextSpellName = "攻击"
        end
    end

    if(aura_env.LastSpellName == NextSpellName) then
        --return true
    else
        aura_env.LastSpellName = NextSpellName
    end

    local start, dur, us, ir, ic
    if (NextSpellName == "超级加速器") then
        start, dur = GetInventoryItemCooldown("player", 10)
        us = true
        ir = true
        ic = GetInventoryItemTexture("player", 10)
    else
        if (NextSpellName == "精灵之火（野性）") then
            start, dur = GetSpellCooldown(16857)
        elseif (NextSpellName == "猛虎之怒") then
            start, dur = GetSpellCooldown(50213)
        elseif (NextSpellName == "狂暴") then
            start, dur = GetSpellCooldown(50334)
        else
            start, dur = GetSpellCooldown(61304)
        end
        us = IsUsableSpell(NextSpellName)
        ir =  (IsSpellInRange(NextSpellName, "target") == 1)
        ic = GetSpellTexture(NextSpellName)
    end

    state[""] = {
        changed = true,
        show = true,
        usable = us,
        inRange = ir,
        progressType = "timed",
        expirationTime = start + dur,
        duration = dur,
        icon = ic
    }
    aura_env.setIconUsable(us)
    aura_env.updateCoverStat(aura_env.findSpellIndex(SpellLists, NextSpellName))
    return true
end


